package com.my.test;

import java.util.concurrent.CountDownLatch;

public class ThreadTask extends Thread{
	
	private Runnable job;
	private long consume;
	private CountDownLatch countDownLatch;
	public ThreadTask(Runnable job,CountDownLatch countDownLatch){
		this.job=job;
		this.countDownLatch=countDownLatch;
	}
	
	public void run(){
		long begin=System.nanoTime();
		try{
			job.run();
		}finally{
			consume=System.nanoTime()-begin;
			countDownLatch.countDown();
		}
	}

	public long getConsume() {
		return consume;
	}
}
